#include <gtest\gtest.h>

#include "Allegro_initialize.h"
#include "digdug.h"
#include "global_variables.h"
#include "movables.h"
#include "game.h"

//Tests for get and set functions of Movables class

TEST(Movables, canSetAndGetAllDataMembers)
{
	Movables movableTest;

	movableTest.set_location(5, 10);
	movableTest.set_x_boundary(1);
	movableTest.set_y_boundary(2);
	movableTest.set_direction(DOWN);
	movableTest.set_speed(5);
	movableTest.set_status(DEAD);
	movableTest.set_object_type(DIGDUG);

	EXPECT_TRUE(movableTest.get_x_location() == 5);
	EXPECT_TRUE(movableTest.get_y_location() == 10);
	EXPECT_TRUE(movableTest.get_x_boundary() == 1);
	EXPECT_TRUE(movableTest.get_y_boundary() == 2);
	EXPECT_TRUE(movableTest.get_direction() == DOWN);
	EXPECT_TRUE(movableTest.get_speed() == 5);
	EXPECT_TRUE(movableTest.get_status() == DEAD);
	EXPECT_TRUE(movableTest.get_object_type() == DIGDUG);

}

//Tests that constructor for digdug initializes the variables correctly
TEST(Digdug, canInitializeDigdug)
{
	int x_location = 10;
	int y_location = 50;
	int speed = 5;
	int lives = 1;

	Digdug digdugTest(x_location, y_location, speed, lives);

	digdugTest.set_location(x_location, y_location);

	EXPECT_TRUE(digdugTest.get_x_location() == x_location);
	EXPECT_TRUE(digdugTest.get_y_location() == y_location);

}


//At this point in project development, the constructor of the game class generates a default map 
//containing sand and holes and initializes a digdug data member to locatiion (45, 45) on the screen map.
//Digdugs speed is initialized to 1 unit/move
//As this form of initialization will be altered in the final project, no unit tests are written for it


//
TEST(Game, canMoveDigDugInSpecifiedDirection)
{
	Game testGame;

	int start_y_position = testGame._dig_dug.get_y_location();
	int start_x_position = testGame._dig_dug.get_x_location();
	int speed = testGame._dig_dug.get_speed();

	testGame.move_Digdug(testGame._dig_dug, RIGHT);

	EXPECT_TRUE(start_y_position  == testGame._dig_dug.get_y_location());
	EXPECT_TRUE(start_x_position  + speed  == testGame._dig_dug.get_x_location());

	testGame.move_Digdug(testGame._dig_dug, UP);

	EXPECT_TRUE(start_y_position - speed  == testGame._dig_dug.get_y_location());
	EXPECT_TRUE(start_x_position + speed  == testGame._dig_dug.get_x_location());

}

int main(int argc, char** argv)
{
	testing::InitGoogleTest(&argc, argv);
	RUN_ALL_TESTS();
	std::getchar();
}